﻿#region Disclaimer/Info

/////////////////////////////////////////////////////////////////////////////////////////////////
//
//   File:		Post.cs
//   Website:		http://dexterblogengine.com/
//   Authors:		http://dexterblogengine.com/About.ashx
//   Rev:		1
//   Created:		19/01/2011
//   Last edit:		19/01/2011
//   License:		GNU Library General Public License (LGPL)
//   File:            Post.cs
//   For updated news and information please visit http://dexterblogengine.com/
//   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
//   For any question contact info@dexterblogengine.com
//
///////////////////////////////////////////////////////////////////////////////////////////////////

#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using Dexter.Domain.Contracts;

namespace Dexter.Domain.Model
{
	public partial class Post : Item, IFeedItem
	{
		internal Post()
		{
			Categories = new List<Category>();
		}

		internal Post(string title, Category category, string username, string formattedBody)
			: base(title, username, formattedBody)
		{
			Categories = new List<Category>();
			if (category != null)
			{
				AddCategory(category);
			}
		}

		/// <summary>
		/// Gets the feed item title.
		/// </summary>
		/// <value>The feed item title.</value>
		public virtual string FeedItemTitle
		{
			get { return this.Title; }
		}

		/// <summary>
		/// Gets the feed item description.
		/// </summary>
		/// <value>The feed item description.</value>
		public virtual string FeedItemDescription
		{
			get { return this.FormattedBody; }
		}

		/// <summary>
		/// Gets the feed item author.
		/// </summary>
		/// <value>The feed item author.</value>
		public virtual string FeedItemAuthor
		{
			get { return this.Username; }
		}

		/// <summary>
		/// Gets the feed item publish date in <c>Coordinated Universal Time</c>.
		/// </summary>
		/// <value>The feed item publish date UTC.</value>
		public virtual DateTime FeedItemPublishDateUtc
		{
			get { return this.PublishDate.ToUniversalTime(); }
		}

		/// <summary>
		/// Gets the feed item categories.
		/// </summary>
		/// <value>The feed item categories.</value>
		public virtual string[] FeedItemCategories
		{
			get { return this.FlatCategories.Select(x => x.Name).ToArray(); }
		}

		/// <summary>
		/// Gets the feed item owner.
		/// </summary>
		/// <value>The feed item owner.</value>
		public virtual Item FeedItemOwner
		{
			get { return this; }
		}
	}
}